package br.com.cfccultura.admin.control.servlet;

import javax.annotation.PostConstruct;
import javax.servlet.ServletContext;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

@Repository
public class InitParamsServlet {
	
	private static final Logger logger = Logger.getLogger(InitParamsServlet.class);
	
	@Autowired
	private ServletContext servletContext;
	
	@Value("${ajax.timeout.void}")
	private Integer ajaxTimeoutVoid;
	
	@Value("${ajax.timeout.return}")
	private Integer ajaxTimeoutReturn;
	
	@Value("${ajax.timeout.data}")
	private Integer ajaxTimeoutData;
	
	@PostConstruct
	public void init() {
		getServletContext().setAttribute("ajaxTimeoutVoid", getAjaxTimeoutVoid());
		getServletContext().setAttribute("ajaxTimeoutReturn", getAjaxTimeoutReturn());
		getServletContext().setAttribute("ajaxTimeoutData", getAjaxTimeoutData());
		logger.info("Context Attributes has been loaded!");
	}

	public Integer getAjaxTimeoutVoid() {
		return ajaxTimeoutVoid;
	}

	public void setAjaxTimeoutVoid(Integer ajaxTimeoutVoid) {
		this.ajaxTimeoutVoid = ajaxTimeoutVoid;
	}

	public Integer getAjaxTimeoutReturn() {
		return ajaxTimeoutReturn;
	}

	public void setAjaxTimeoutReturn(Integer ajaxTimeoutReturn) {
		this.ajaxTimeoutReturn = ajaxTimeoutReturn;
	}

	public Integer getAjaxTimeoutData() {
		return ajaxTimeoutData;
	}

	public void setAjaxTimeoutData(Integer ajaxTimeoutData) {
		this.ajaxTimeoutData = ajaxTimeoutData;
	}
	
	public ServletContext getServletContext() {
		return servletContext;
	}
	public void setServletContext(ServletContext servletContext) {
		this.servletContext = servletContext;
	}

}
